package cn.ecut.service.impl;


import cn.ecut.dao.TaofangDao;
import cn.ecut.model.Loudong;
import cn.ecut.model.Taofang;
import cn.ecut.service.Taofangservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.DecimalFormat;
import java.util.List;

@Service
public class Taofangserviceimpl implements Taofangservice {
    @Autowired
    private TaofangDao taofangDao;

    @Override
    public List<Taofang> selectAll() {
        return taofangDao.selectAll();
    }

    @Override
    public int selectAllcount() {
        return taofangDao.selectAllcount();
    }

    @Override
    public int insert(Taofang taofang) {
        return taofangDao.insert(taofang);
    }

    @Override
    public Loudong selectLoudong(String loudongbianma) {
        return taofangDao.selectLoudong(loudongbianma);
    }

    @Override
    public String gettaofangBianma() {
        DecimalFormat decimalFormat=new DecimalFormat("00000");
        String s = taofangDao.selectThelast();
        s=s.substring(2);
        System.out.println(s);
        int i=Integer.parseInt(s)+1;
        String k=decimalFormat.format(i);
        String taofangBianma = "TF"+k;
        System.out.println(taofangBianma);
        return taofangBianma;
    }

    @Override
    public int updateByPrimaryKey(Taofang taofang) {
        return taofangDao.updateByPrimaryKey(taofang);
    }

    @Override
    public int updateQiyong(Taofang taofang) {
        return taofangDao.updateQiyong(taofang);
    }

    @Override
    public List<Taofang> advanceSelect(String s) {
        return taofangDao.advanceSelect(s);
    }

    @Override
    public int deleteByPrimaryKey(String taofangbianma) {
        return taofangDao.deleteByPrimaryKey(taofangbianma);
    }
}
